package vip.xiaonuo.smzq.modular.kcl.controller;

import javax.annotation.Resource;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import vip.xiaonuo.smzq.modular.kcl.entity.Zhhs;
import vip.xiaonuo.smzq.modular.kcl.entity.vo.ZhhsDetails;
import vip.xiaonuo.smzq.modular.kcl.service.IZhhsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import vip.xiaonuo.common.pojo.CommonResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;


/**
 * 综合回收
 *
 * @author eomer
 * @since 2024-02-22
 */
@Api(tags = "综合回收")
@RestController
@RequestMapping("/kcl/zhhs")
@Validated
public class ZhhsController {

    @Resource
    private IZhhsService iZhhsService;

    /**
     * 添加综合回收
     */
    @ApiOperation("添加综合回收")
    @PostMapping("/add")
    public CommonResult<String> add(@RequestBody @Valid Zhhs zhhs) {
        iZhhsService.save(zhhs);
        return CommonResult.ok();
    }

    /**
     * 删除综合回收
     */
    @ApiOperation("删除综合回收")
    @PostMapping("/delete")
    public CommonResult<String> delete(@ApiParam(name = "pkid", value = "主键") @RequestParam String pkid) {
        iZhhsService.removeById(pkid);
        return CommonResult.ok();
    }

    /**
     * 编辑综合回收
     */
    @ApiOperation("编辑综合回收")
    @PostMapping("/edit")
    public CommonResult<String> edit(@RequestBody @Valid Zhhs zhhs) {
        iZhhsService.updateById(zhhs);
        return CommonResult.ok();
    }

    /**
     * 综合回收分页查询
     */
    @ApiOperation("综合回收分页查询")
    @GetMapping("/list")
    public CommonResult<Page<Zhhs>> page() {
        return CommonResult.data(iZhhsService.page(new Zhhs()));
    }

    /**
     * 综合回收详情查询
     */
    @ApiOperation("综合回收详情查询")
    @GetMapping("/getZhhsList")
    public CommonResult<List<ZhhsDetails>> getZhhsList(
            @ApiParam(name = "kqbm", value = "矿区编码", required = true) @RequestParam String kqbm,
            @ApiParam(name = "djflbm", value = "登记分类编码", required = true) @RequestParam Integer djflbm,
            @ApiParam(name = "nd", value = "年度", required = true) @RequestParam Integer nd
    ) {
        return CommonResult.data(iZhhsService.getZhhsList(kqbm, djflbm, nd));
    }
}
